<?php

defined('_JEXEC') or die('Retricted Access');
if(!$fieldEditList) return ;

?>
 <script type="text/javascript">
/* <![CDATA[ */
 	<?php if(JRequest::getVar('layout')=='jalist'){?>
	var url = location.href;
	pos = url.indexOf('#');
	if(pos > 0) {
		location.href = url.substr(0, pos+1)
	}
	<?php }?>
	
	var siteurl = '<?php echo JURI::base();?>';
	var select_text = '<?php echo JText::_('jobs selected')?>';
	var number_items_search = '<?php echo $param['number_items'];?>';
/* ]]> */
</script>
 
<?php
$db = JFactory::getDBO();
$jobalert_id = JRequest::getVar('cid');
if (JRequest::getVar('view')=='jajobs'&&JRequest::getVar('layout')=='jalist'&&$jobalert_id[0])
{
	
	$query = "SELECT * FROM #__ja_jobalerts WHERE id=".$jobalert_id[0];
	$db->setQuery($query);
	$jobalert = $db->loadObject();
	if ($jobalert && $jobalert->keyword)
	{
		if ($jobalert->keyword_option=='3')
			JRequest::setVar('filter_keyword','"'.$jobalert->keyword.'"');
		else
			JRequest::setVar('filter_keyword',$jobalert->keyword);
			
	}
}
else 
	$jobalert= null;

$menu =& JSite::getMenu();
$item =& $menu->getActive();
global $jbconfig;
$keyword = JRequest::getVar('filter_keyword', JText::_('Enter keyword...'));

$query = "SELECT * FROM #__menu WHERE (link='index.php?option=com_jajobboard&view=jajobs&layout=jalist' OR link='index.php?option=com_jajobboard&view=jajobs&layout=myjobs' OR link='index.php?option=com_jajobboard&view=jajobs&layout=jajobseekerlist') AND (access=0)";
$db->setQuery($query);
$direct_Itemid = $db->loadObjectList();



if (isset($direct_Itemid[0]))
	$direct_Itemid = $direct_Itemid[0]->id;
else 	
	$direct_Itemid = '';
?>
<?php if(!defined('JAJOBBOARD_MOD_FILTERJOBS_JS')){?>
	<script type="text/javascript" language="javascript">
	//<![CDATA[
		var Itemid = '<?php echo @$item->id;?>';
		var direct_Itemid = '<?php echo @$direct_Itemid; ?>';
		Cookie.set('doSearchs_job', '1', {duration: 1});
	//]]>
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo JURI::base();?>modules/mod_jafilter_jobs/ja_filter_jobs/js/ja.filterjobs.js"></script>
	<?php define('JAJOBBOARD_MOD_FILTERJOBS_JS', 1);?>
<?php }?>
<script type="text/javascript">
/* <![CDATA[ */	
	var itemid = '<?php echo JRequest::getVar('Itemid'); ?>';
	var filter = new Array(<?php echo count($fieldEditList);?>);
	var parent = new Array(<?php echo count($fieldEditList);?>);
	<?php 
	$count_temp = 0;
	for ($i=0;$i<count($fieldEditList);$i++)
		if (isset($fieldEditList[$i]->field_type))
		if (($fieldEditList[$i]->field_type=='SELECT')||($fieldEditList[$i]->field_type=='MSELECT'))
		{
	?>
			
			filter[<?php echo $count_temp;?>] = '<?php echo $fieldEditList[$i]->field_name?>';
			<?php for ($j=0;$j<count($filter_fields[$i]);$j++)
					if (isset($filter_fields[$i][$j]->parent_id)){?>			 
				parent["<?php echo $fieldEditList[$i]->field_name?>_<?php echo $filter_fields[$i][$j]->id?>"] = "<?php echo $filter_fields[$i][$j]->parent_id;?>";								
			<?php }
	$count_temp++;}?>
	filter.length = <?php echo $count_temp; ?>;
	
/* ]]> */
</script>

<!-- KEYWORD FILTER -->
<div id="ja-filter-jobs">

	<ul class="menu">
		
<!-- END -->
<!--BLOCK: FILTERS ACCORDION-->
		

	<?php for ($i=0;$i<count($fieldEditList);$i++){
	   
		$field = $fieldEditList[$i]; 
				
		$active = '';
		if (is_object($field) && (($field->field_type=='SELECT')||($field->field_type=='MSELECT') ))
		{
	?>
		<li>
    		
	    		<a href="javascript:void(0)" onclick="show_div_filter('div-filter-<?php echo $field->field_name; ?>-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');">
	    			<?php echo JText::_($field->label);?>:
	    		</a>
    		
	    	<div id="filter-inactive-<?php echo $field->field_name; ?>">
	    		<?php echo JText::_('All'); ?>
			</div>
			<div id="filter-active-<?php echo $field->field_name; ?>" style="display:none;">
	    		
			</div>
	    	<div class="div-filter-<?php echo $param['popup_position']; ?>" id="div-filter-<?php echo $field->field_name; ?>-<?php echo $param['popup_position']; ?>">
	    		<div class="div-header">
	    			
	    			<table width="95%">
						<tr>
							<td>
			    				<?php echo JText::_($field->label); ?>
			    			</td>
			    			<td align="right">
			    				<label style="cursor:pointer;" class="ja-filterjob-apply" onclick="doSearchs();show_div_filter('div-filter-<?php echo $field->field_name; ?>-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');"><?php echo JText::_('Apply'); ?></label>
			    				&nbsp;
			    				<label style="cursor:pointer;" class="ja-filterjob-close" onclick="show_div_filter('div-filter-<?php echo $field->field_name; ?>-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');"><?php echo JText::_('Close'); ?></label>
			    			<td>
	    				</tr>
	    			</table>
	    		</div>
	    		<br />
		    	<div class="content-filter">
					<form action="#" method="post" name="<?php echo 'form_'.$field->field_name; ?>" >
		    			<?php if(isset($filter_fields[$i][0]))  if ($modHelper->check_multi_level($filter_fields[$i][0]))
		    					$modHelper->display_mulLevel_Select($filter_fields[$i], $field,$jobalert);
		    				  else 
		    				  	$modHelper->dislay_singLevel_Select($filter_fields[$i], $field,$jobalert);
		    			?>	
		    			
		    			<input type="hidden" name="filter_<?php echo $field->field_name; ?>" value="" />
		    			
		    		</form>
		    	</div>
	    	</div>	
    	</li>
	<?php 
		}
	}?>	
	
	<?php if($enabled_salary_field){?>
		<li>
			<a href="javascript:void(0)" onclick="show_div_filter('div-filter-salary-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');">
				<?php echo JText::_('Salary').':';?>
			</a>
			<div id="filter-inactive-salary">
	    		<?php echo JText::_('All'); ?>
			</div>
			<div id="filter-active-salary" style="display:none;">
	    		
			</div>
			<div id="div-filter-salary-<?php echo $param['popup_position']; ?>">
				<div class="div-header">
					<table width="100%">
						<tr>
							<td>
			    				<?php echo JText::_('Salary')." (".$jbconfig['currency']->get('currency').")"; ?>
			    			</td>
			    			<td align="right">
			    				<label  class="ja-filterjob-apply" style="cursor:pointer;" onclick="doSearchs();show_div_filter('div-filter-salary-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');"><?php echo JText::_('Apply'); ?></label>
			    				&nbsp;
			    				<label class="ja-filterjob-close" style="cursor:pointer;" onclick="show_div_filter('div-filter-salary-<?php echo $param['popup_position']; ?>','<?php echo $param['popup_position']; ?>');"><?php echo JText::_('Close'); ?></label>
			    			<td>
	    				</tr>
	    			</table>
	    		</div>
	    		<br />
				<form action="#" method="post" name="<?php echo 'form_salary'; ?>" >
					<table>
						<tr>
							<td>
								<label for="filter_salary_from"><?php echo JText::_('Salary from'); ?></label><br />
								<input type="text" onkeyup="NumberOnly(this)" class="inputbox" id="filter_salary_from" value="<?php echo JRequest::getVar('filter_salary_from'); ?>" name="filter_salary_from"/>
							</td>
							<td>
								<label for="filter_salary_to"><?php echo JText::_('Salary to'); ?></label> <br />
								<input type="text" onkeyup="NumberOnly(this)" class="inputbox" id="filter_salary_to" value="<?php echo JRequest::getVar('filter_salary_to'); ?>" name="filter_salary_to"/>
							</td>
						</tr>
					</table>
				</form>			
			</div>
		</li>	
	<?php }?>
	</ul>
	<div id="div-filter-keyword">
		<form name="form_keyword" method="POST" onsubmit="doSearchs();" action="javascript:void(0);">
		<!--<label for="filter_keyword"><?php echo JText::_('Keyword') ?></label><br />-->
		<?php if ($keyword==JText::_('Enter keyword...')) {?>
			<input onblur="lost_focus_keyword('<?php  echo $keyword?>')" onfocus="focus_keyword('<?php  echo $keyword?>')" style="color:#858783;" type="text" size="22" id="filter_keyword" name="filter_keyword" value='<?php echo $keyword; ?>' />
		<?php } else {?>
			<input type="text" size="22" id="filter_keyword" name="filter_keyword" value='<?php echo $keyword; ?>' />
		<?php } ?> 
		<br />
		<small><?php echo JText::_("EG: ACCOUNTING, FINANCE, INFORMATION TECHNOLOGY..."); ?></small>
		<input type="hidden" name="default_keyword" value="<?php echo JText::_('Enter keyword...'); ?>" id="default_keyword" />
		</form>
	</div>	
			
		
<!--END-->

		<div style="text-align:center; margin-top:15px;">
		
			<input type="button"  value="<?php echo JText::_('Search')?>" onclick="doSearchs(<?php if(JRequest::getInt('limit')) echo JRequest::getInt('limit');?>);show_div_filter('close','<?php echo $param['popup_position']; ?>');" /> 
			<input type="button"  value="<?php echo JText::_('Reset')?>" onclick="reset(<?php if(JRequest::getInt('limit')) echo JRequest::getInt('limit');?>);" />
		</div>

</div>

<input type="hidden" name="is_filterform" value="1" />

<script type="text/javascript">
/* <![CDATA[ */		
	window.addEvent('load', function(){		
		buildData();
	});
	
/* ]]> */
</script>

<script type="text/javascript" language="javascript">
//<![CDATA[
	var siteurl = '<?php echo JURI::base();?>';
	var Itemid  = '<?php echo @$Itemid; ?>';
	var redirect_url = '<?php echo JRoute::_('index.php?option=com_jajobboard&view=jajobs&layout=filter_job_list&Itemid='.$Itemid);?>';
	redirect_url = redirect_url.replace(/&amp;/gi, '&');
	Cookie.set('doSearchs_job', '1', {duration: 1});

//]]>
</script>